using IQIGame.Onigao.Framework;
using UnityEditor;

namespace IQIGame.Onigao.GamePlay.Editors
{
    public static class EditorEnterMode
    {
        private static EditorPreferenceInt enterMode = new EditorPreferenceInt(PlayerPrefsConst.GameEnterMode);

        static EditorEnterMode()
        {
            SetCheck();
        }

        [InitializeOnLoadMethod]
        private static void SetCheck()
        {
            var nMode = enterMode.Value;
            Menu.SetChecked("GameEditor/EditorEnterMode/Level", nMode == (int)EnterGameType.Level);
            Menu.SetChecked("GameEditor/EditorEnterMode/Battle", nMode == (int)EnterGameType.Battle);
            Menu.SetChecked("GameEditor/EditorEnterMode/Login", nMode == (int)EnterGameType.Login);
            ProcedureGame.enterMode = (EnterGameType)nMode;
        }


        [MenuItem("GameEditor/EditorEnterMode/Level")]
        public static void Level()
        {
            enterMode.Value = (int)EnterGameType.Level;
            SetCheck();
        }

        [MenuItem("GameEditor/EditorEnterMode/Battle")]
        public static void Battle()
        {
            enterMode.Value = (int)EnterGameType.Battle;
            SetCheck();
        }

        [MenuItem("GameEditor/EditorEnterMode/Login")]
        public static void Login()
        {
            enterMode.Value = (int)EnterGameType.Login;
            SetCheck();
        }

    }
}